<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/view/include/taglib.jsp"%>
<html lang="cn" class="app">
<head>
    <meta charset="utf-8" />
    <title>RCode | 睿代码管理平台 | 提示管理</title>
    <meta name="description" content="app, web app, responsive, admin dashboard, admin, flat, flat ui, ui kit, off screen nav" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="icon" type="image/png" href="icon.png">
    <link rel="apple-touch-icon-precomposed" href="icon.png">
    <link rel="stylesheet" href="${ctxStatic}/js/jPlayer/jplayer.flat.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/animate.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/simple-line-icons.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/font.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/css/app.css" type="text/css" />
    <link rel="stylesheet" href="${ctxStatic}/js/ztree/css/zTreeStyle.css">
    <%--<link rel="stylesheet" href="${ctxStatic}/js/page/paging.css" type="text/css" />--%>
    <!--[if lt IE 9]>
    <script src="${ctxStatic}/js/ie/html5shiv.js"></script>
    <script src="${ctxStatic}/js/ie/respond.min.js"></script>
    <script src="${ctxStatic}/js/ie/excanvas.js"></script>
    <![endif]-->
</head>
<body>
<section class="scrollable wrapper">
    <div class="row">
        <div class="col-lg-12">
            <!-- 引导开始 -->
            <ul class="breadcrumb">
                <li><a href="${ctx}/welcome"><i class="fa fa-home"></i> 主页</a></li>
                <li>系统设置</li>
                <li class="active">提示管理</li>
                <li class="active">提示新增</li>
            </ul>
            <!-- 引导结束 -->
        </div>
    </div>
    <form class="bs-example form-horizontal" method="post" action="${ctx}/sys/tip/update" >
    <section class="panel panel-default">
        <%--基本信息--%>
            <section class="panel panel-default">
                <header class="panel-heading font-bold">提示新增</header>
                <%--<input type="hidden" name="parentId" value="${tip.id}" />--%>
                <input type="hidden" name="id" value="${sysTipVo.id}" />
                <input type="hidden" id="parentId" name="parentId" value="${sysTipVo.parentId}" />
                <input type="hidden" id="parentIds" name="parentIds" value="${sysTipVo.parentIds}" />
                <div class="panel-body">
                        <div class="form-group">
                            <label class="col-lg-2 col-md-2 col-sm-2 control-label">上级提示：</label>
                            <div class="col-lg-6 col-md-6 col-sm-6 ">
                                <input type="text" class="form-control" id="parentName" minlength="1" value="${sysTipVo.sysTipVo.name}" readonly>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-4 ">
                                <button id="menuBtn" type="button" class="btn btn-s-md btn-default">选择</button>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 col-md-2 col-sm-2 control-label">提示名称：</label>
                            <div class="col-lg-10 col-md-10 col-sm-10">
                                <input type="text"  name="name" class="form-control" placeholder="提示名称（必填）" value="${sysTipVo.name}" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 col-md-2 col-sm-2 control-label">提示内容：</label>
                            <div class="col-lg-10 col-md-10 col-sm-10">
                                <textarea name="content" class="form-control" placeholder="提示内容（必填）" required>${sysTipVo.content}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 col-md-2 col-sm-2 control-label">是否可用：</label>
                            <div class="col-lg-10 col-md-10 col-sm-10">
                                <select name="available" class="form-control" >
                                    <c:forEach items="${yn}" var="m">
                                        <option value="${m.value}" <c:if test="${sysTipVo.available==m.value}">selected="selected"</c:if>>${m.label}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 col-md-2 col-sm-2 control-label">提示内容：</label>
                            <div class="col-lg-10 col-md-10 col-sm-10">
                                <textarea name="remarks" class="form-control" placeholder="备注" required>${sysTipVo.remarks}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-lg-offset-2 col-lg-10 col-md-offset-2 col-md-10 col-sm-offset-2 col-sm-10">
                                <shiro:hasPermission name="sys:tip:edit">
                                    <button type="submit" class="btn btn-s-md btn-info">保存</button>
                                </shiro:hasPermission>
                                <button type="button" class="btn btn-s-md btn-danger" onclick="closeModel(false)">关闭</button>
                            </div>
                        </div>
                </div>

            </section>



    </section>
    </form>
</section>
<div id="menuContent" class="menuContent" style="display:none;position: absolute;z-index: 10000;background-color: #eee;border: 1px solid #ccc;">
    <style>.line{height:auto;}</style><%--这个不能删除--%>
    <ul id="tree" class="ztree" style="margin-top:0;"></ul>
</div>
</body>
<script src="${ctxStatic}/js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="${ctxStatic}/js/bootstrap.js"></script>
<!-- App -->
<script src="${ctxStatic}/js/app.js"></script>
<script src="${ctxStatic}/js/slimscroll/jquery.slimscroll.min.js"></script>
<script src="${ctxStatic}/js/app.plugin.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/jPlayer/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/jPlayer/add-on/jplayer.playlist.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/jPlayer/demo.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/tools.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/page/paging.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/layer/layer.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/tmpl/jquery.tmpl.js"></script>
<script src="${ctxStatic}/js/ztree/js/jquery.ztree.core-3.5.min.js"></script>

<script>
    $(function(){
        var msg = '${msg}';
        if(msg!=''){
            showMsg(msg);
            closeModel(true);//关闭窗口
        }

        var setting = {
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback : {
                onClick : function(event, treeId, treeNode) {
                    //点击回调方法
                    ztreeOnClickCall && ztreeOnClickCall(treeNode);
                    $("#parentName").val(treeNode.name);
                    hideMenu();
                }
            }
        };
        var zNodes =[
            <c:forEach items="${tipList}" var="o" varStatus="status">
            { id:${o.id}, pId:${o.parentId},pIds:'${o.parentIds}', name:"${o.name}", open:true}<c:if test="${!status.last}">,</c:if>
            </c:forEach>
        ];
        $(document).ready(function(){
            var ztree = $.fn.zTree.init($("#tree"), setting, zNodes);
            ztree.expandAll(true);
        });

        $("#menuBtn").click(showMenu);
    })

    //ztree点击回调
    function ztreeOnClickCall(treeNode){
        $("#parentId").val(treeNode.id);
        $("#parentIds").val(treeNode.pIds+treeNode.id+"/");
    }
    //展示树选择区域
    function showMenu() {
        var cityObj = $("#parentName");
        var cityOffset = $("#parentName").offset();
        $("#menuContent").css({
            left: cityOffset.left + "px",
            top: cityOffset.top + cityObj.outerHeight() + "px"
        }).slideDown("fast");

        $("body").bind("mousedown", onBodyDown);
    }
    //隐藏树选择区域
    function hideMenu() {
        $("#menuContent").fadeOut("fast");
        $("body").unbind("mousedown", onBodyDown);
    }
    //点击其他区域事件-用于隐藏选择树
    function onBodyDown(event) {
        if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length > 0)) {
            hideMenu();
        }
    }

</script>
</html>
